package com.ssy.lingxi.message.handler.exception;//package com.ssy.lingxi.platform.template.service.handler.exception;
//
//import com.netflix.hystrix.exception.HystrixRuntimeException;
//import com.ssy.lingxi.common.exception.BusinessException;
//import com.ssy.lingxi.common.response.ResponseCode;
//import com.ssy.lingxi.common.response.Wrapper;
//import org.springframework.core.annotation.Order;
//import org.springframework.web.bind.annotation.ExceptionHandler;
//import org.springframework.web.bind.annotation.RestControllerAdvice;
//
//import javax.servlet.http.HttpServletRequest;
//
///**
// * 全局自定义服务调用异常处理类
// * @author jw.chen
// * @version 2.0.0
// * @date 2020/6/22
// */
//@RestControllerAdvice
//@Order(10)
//public class HystrixExceptionHandler {
//    @ExceptionHandler(HystrixRuntimeException.class)
//    public Wrapper<?> validationBodyException(HttpServletRequest request, HystrixRuntimeException exception) {
//        if(exception.getFallbackException().getCause().getCause() instanceof BusinessException){
//            BusinessException businessException = (BusinessException) exception.getFallbackException().getCause().getCause();
//            return Wrapper.fail(businessException.getCode(), businessException.getNameByCode());
//        }else{
//            return Wrapper.fail(ResponseCode.BUSINESS_ERROR);
//        }
//    }
//}
